package com.example.demo.buessiness.company.repository;

import com.example.demo.buessiness.company.model.po.Company;
import com.example.demo.buessiness.user.model.po.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;


public interface CompanyRepository extends JpaRepository<Company,Long> {

      List<Company> findAllByOrderByIdAsc();
      Page<Company> findAll(Specification<Company> spec, Pageable pageable);

      @Modifying
      @Query(value = "update Company c set c.address=:address where c.id=:id",nativeQuery=true)
      void modifyCompanyByName(@Param("address")String address, Long id);


      /**
       * 查询公司名
       * @param company
       */
      @Modifying
      @Query(value = "SELECT * FROM company WHERE company = ?1 ",nativeQuery=true)
      List<Company> findByCompany(String company);


}
